package com.bluesky.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bluesky.system.common.dto.SysLogQueryDTO;
import com.bluesky.system.entity.SysLog;
import com.bluesky.system.mapper.SysLogMapper;
import com.bluesky.system.service.ISysLogService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 操作日志表  服务实现类
 * </p>
 *
 * @author Kevin
 * @since 2021-07-12
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements ISysLogService {

    @Override
    public IPage<SysLog> page(Page reqPage, SysLogQueryDTO req) {
        LambdaQueryWrapper<SysLog> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.like(StrUtil.isNotBlank(req.getTitle()), SysLog::getTitle, req.getTitle());
        queryWrapper.like(StrUtil.isNotBlank(req.getLogStatus()), SysLog::getLogStatus, req.getLogStatus());
        queryWrapper.like(StrUtil.isNotBlank(req.getUserPlatform()), SysLog::getUserPlatform, req.getUserPlatform());
        queryWrapper.like(StrUtil.isNotBlank(req.getOperName()), SysLog::getOperName, req.getOperName());
        queryWrapper.orderByDesc(SysLog::getCreatedTime);
        return this.page(reqPage, queryWrapper);
    }

    @Override
    public SysLog view(String id) {
        return this.getById(id);
    }

}
